package qj.pooling;

/**
 * This interface is for a pool manager: declare an object life-cycle.<br>
 * <br>
 * Created by QuanLA<br>
 * Date: Mar 31, 2006<br>
 * Time: 2:03:27 PM<br>
 */
public interface PoolManagable {
    /**
     * Called after release an object.
     *
     * @param obj
     * @return false if the object can not be bath, the object will be
     *          rejected off the pool.
     */
    boolean bath(Object obj);

    /**
     * Called before the object is acquired.
     * <br>
     * Make sure that the created new object can be prepared
     * or the pool will throw exception when acquired.
     * 
     * @param obj
     * @return false if the ready object cannot be prepared, the object then will
     *          be rejected off the pool.
     */
    boolean prepare(Object obj);

    /**
     * This will be call when pool increase size.
     * 
     * @return Object that will be put into pool
     */
    Object createNew();

    /**
     * Called when object is kicked of the pool.
     * 
     * @param obj
     */
    void destroy(Object obj);
}
